﻿Imports System.Data.SqlClient
Public Class clsAltas
    Private mintIdAlta As Integer
    Private mintIdEmpleado As Integer
    Private mstrReportado As String
    Private mstrUsuario As String

    Public Property idAlta() As Integer
        Get
            Return mintIdAlta
        End Get
        Set(ByVal value As Integer)
            mintIdAlta = value
        End Set
    End Property

    Public Property IdEmpleado() As Integer
        Get
            Return mintIdEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIdEmpleado = value
        End Set
    End Property
    Public Property Reportado() As String
        Get
            Return mstrReportado
        End Get
        Set(ByVal value As String)
            mstrReportado = value
        End Set
    End Property
    Public Property Usuario() As String
        Get
            Return mstrUsuario
        End Get
        Set(ByVal value As String)
            mstrUsuario = value
        End Set
    End Property

    Public Sub New()
        mintIdAlta = 0
        mintIdEmpleado = 0
        mstrReportado = ""
        mstrUsuario = ""
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into Altas (" & _
                            "IdAlta," & _
                            "IdEmpleado," & _
                            "Reportado," & _
                            "Usuario)" & _
                            "VALUES (" & _
                            "@IdAlta," & _
                            "@IdEmpleado," & _
                            "@Reportado," & _
                            "@Usuario)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdAlta", mintIdAlta)
        Command.Parameters.AddWithValue("IdEmpleado", mintIdEmpleado)
        Command.Parameters.AddWithValue("Reportado", mstrReportado)
        Command.Parameters.AddWithValue("Usuario", mstrUsuario)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
